# 自动打包
workdir=$(cd $(dirname $0); pwd)
cd $workdir
echo workdir dir:$(pwd)

echo update version
chmod +x bash_update_version.sh
./bash_update_version.sh

rm -rf *.tgz
charts=$(find $workdir|grep Chart.yaml)

for chart in $charts
do
echo "Charts:${chart}"
# dirs of current chart,such as drill and spark
dir_name=$(echo $chart|awk -F"/" '{print $(NF-1)}')
echo "dir name: $dir_name"
cd $dir_name
echo current dir is :$(pwd)
rm -rf *.tgz
helm package .

if [ $? -eq 0 ];then
echo build success.
else
exit
fi

echo change dir to workdir
cd $workdir

echo "-----------------------------------------"
echo 
echo 
done

echo start to create index...
helm repo index .  --url https://gitee.com/gsunwu/BigDataHemlRepo/raw/master/

echo start to update to online repo...
git add --all

# Input your commit message
set commitMessage
echo "Input your commit message"
read commitMessage


git commit -m "$commitMessage"
git push origin master